<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../../css/allApp.css" />
		<link rel="stylesheet" href="css/css.css" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<style>
			.beizhu {
				display: none;
			}
			.mui-content {
				padding-bottom: 70px;
			}
			
			.mui-right-title {
				color: #007AFF;
			}
			
			.sp-title.p10 {
				padding: 0 10px;
			}
			
			.sp-title.p10 span {
				font-size: 15px;
			}
			
			.sp-group {
				text-align: center;
				display: inline-block;
			}
			
			.mui-popover-add {
				top: 50%!important;
				width: 90%;
				margin-left: 5%;
				background: #ffffff;
				padding-top: 10px;
				transform: translateY(-50%);
				-ms-transform:translateY(-50%); 	/* IE 9 */
				-moz-transform:translateY(-50%); 	/* Firefox */
				-webkit-transform:translateY(-50%); /* Safari 和 Chrome */
				-o-transform:translateY(-50%); 	/* Opera */
				position: fixed;
			}
			
			input.w50 {
				width: 50%;
			}
			
			input.w30 {
				width: 30%;
			}
			
			input.w25 {
				width: 25%;
			}
			
			#lineChart {
				height: 260px;
				background: #fff;
				padding: 5px 10px;
				/*margin-top: 10px;*/
			}
			
			#lineChart1 {
				height: 260px;
				background: #fff;
				padding: 5px 10px;
				/*margin-top: 10px;*/
			}
			
			.radio .voltage .input_v {
				width: 3rem;
			}
			
			.radio .voltage label {
				font-size: 0.88rem;
			}
			
			.tishi {
				text-align: center;
				font-size: 0.8rem;
			}
			
			.mui-left.title,
			.mui-left.Title {
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
				width: 80%;
				text-align: left;
			}
			.fs15{
				font-size: 15px;
			}
			.pd5{
				padding-bottom:5px;
			}
			.ifshowssd{
				display: none;
			}
			.sp-groupblock{
				display: flex;
				justify-content: center;
				align-items:center;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">巡检项填写</h1>
		</header>
		<div class="mui-content">
			<div class="fj-content" id="rate_id">
				<div class="mui-row fj-row" id="shebei">
					<span class="mui-pull-left">设备信息</span>
					<a class="mui-icon mui-icon-arrowright mui-icon-right-nav mui-pull-right"></a>

				</div>
				<div class="mui-row fj-row hide" id="shebeimc">
					<span class="mui-pull-left"></span>
				</div>
				<div class="mui-row fj-row hide" id="shebeibh">
					<span class="mui-pull-left"></span>
				</div>
			</div>
			<h5 class="title">巡检项目</h5>
			<div class="xj-content" id="">
				<!--<div class="mui-card">
					<div class="mui-card-header">
						<div class="mui-left Title">
							1 风机机位状况
						</div>
						<div class="mui-right mui-col-sm-2 mui-col-xs-2 mui-right-title">
							标准<span style="display:none;">1.导线与公路导线与公路导线与公路导线与公路导线与公路</span>
						</div>
					</div>
					<div class="mui-card-content">
						<div class="mui-row">
							<div class="form-row mui-pull-left">
								<em class="mui-pull-left">状态:</em>
								<div class="radio mui-pull-left">
									<form action="">
										<div class="mui-radio mui-pull-left">
											<label>正常</label>
											<input name="radio1" type="radio" value="正常"></div>
										<div class="mui-radio mui-pull-left">
											<label>异常</label>
											<input name="radio1" type="radio" value="异常"></div>
									</form>
								</div>
							</div>
							<div class="mui-pull-right yichang hide">
								<button type="button" class="mui-btn mui-btn-primary">异常填写</button>
							</div>
						</div>
						<p class="beizhu"></p>
						<div class="img-up">
							<div class="photo">
								<img src="" alt="" class="headimg" />
								<span class="mui-icon mui-icon-closeempty delete"></span>
							</div>
							<div class="img" id="userImg">
								<span class="mui-icon mui-icon-image"></span>
								<p>拍照上传</p>
							</div>
						</div>
					</div>
				</div>-->
				<!--<div class="mui-card">
					<div class="mui-card-header">
						<div class="mui-left Title">
							2 风机机位状况
						</div>
						<div class="mui-right mui-col-sm-6 mui-col-xs-6 mui-right-title">
							标准:2.导线与公路导线与公路导线与公路导线与公路导线与公路
						</div>
					</div>
					<div class="mui-card-content">
						<div class="mui-row">
							<div class="form-row mui-pull-left mui-col-sm-7 mui-col-xs-7">

								<div class="radio mui-pull-left">
									<em class="mui-pull-left">温度:</em>
									<form action="" class="mui-pull-left">
										<input type="text" class="input" readonly="readonly"data-type="1" />
									</form>
								</div>
							</div>
							<div class="mui-pull-right yichang">
								<button type="button" class="mui-btn mui-btn-primary">异常填写</button>
							</div>
						</div>
						<div class="img-up">
							<div class="photo">
								<img src="" alt="" class="headimg" />
								<span class="mui-icon mui-icon-closeempty delete"></span>
							</div>
							<div class="img" id="userImg">
								<span class="mui-icon mui-icon-image"></span>
								<p>拍照上传</p>
							</div>
						</div>
					</div>
				</div>-->

				<!--<div class="mui-card">
					<div class="mui-card-header">
						<div class="mui-left Title">
							2 风机机位状况
						</div>
						<div class="mui-right mui-col-sm-6 mui-col-xs-6 mui-right-title">
							标准:2.导线与公路导线与公路导线与公路导线与公路导线与公路
						</div>
					</div>
					<div class="mui-card-content">
						<div class="mui-row">
							<div class="form-row mui-pull-left mui-col-sm-7 mui-col-xs-7">

								<div class="radio mui-pull-left input_vol"data-type="2">
									<em class="">温度:</em>
									<form action="" class="voltage">
										<label for="">A:</label><input type="text" class="input_v" readonly="readonly" />
										<label for="">B:</label><input type="text" class="input_v" readonly="readonly" />
										<label for="">C:</label><input type="text" class="input_v" readonly="readonly"  />
									</form>
								</div>
							</div>
							<div class="mui-pull-right yichang ">
								<button type="button " class="mui-btn mui-btn-primary ">异常填写</button>
							</div>
						</div>
						<div class="img-up ">
							<div class="photo ">
								<img src=" " alt=" " class="headimg " />
								<span class="mui-icon mui-icon-closeempty delete "></span>
							</div>
							<div class="img " id="userImg ">
								<span class="mui-icon mui-icon-image "></span>
								<p>拍照上传</p>
							</div>
						</div>
					</div>
				</div>-->
			</div>
			<div class="btn">
				<button type="button" class="mui-btn mui-btn-primary mui-col-xs-12 " id="sure">确定</button>
			</div>
		</div>
		<div id="topPopover" class="mui-popover mui-popover-add" data-type="">
			<div class="sp-title mui-row p10">
				<h4 class="mui-pull-left">电流</h4>
				<span class="mui-pull-right ">本数据显示前十次数据</span>
			</div>
			<div class="sp-group ios sp-groupblock"> 
				<label for=" ">今日数据：</label><input type="text" style="margin-bottom: 0px;" name="usernames " id="bianhao" placeholder="请输入数字 " class="w50" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" /><span class="ifshowssd">℃</span>
			</div>
			<div class="sp-group android sp-groupblock">
				<label for=" ">今日数据：</label><input type="tel" style="margin-bottom: 0px;" name="usernames " id="bianhao" placeholder="请输入数字 " class="w50" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" /><span class="ifshowssd">℃</span>
			</div>
			<div class="chart" id="lineChart"></div>
			<div class="tishi"></div>
			<div class="sp-submit ">
				<div class="sp-submit-quit">
					取消
				</div>
				<div class="sp-submit-sure">
					确定
				</div>
			</div>
		</div>
		<div id="topPopover1" class="mui-popover mui-popover-add" data-type="">
			<div class="sp-title mui-row p10 ">
				<h4 class="mui-pull-left ">温度</h4>
				<span class="mui-pull-right ">本数据显示前十次数据</span>
			</div>
			<div class="sp-group ios">
				<label for=" ">今日数据：</label><input type="text" name="usernames " id="bianhao1" placeholder="A相 " class="w25" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" />/<input type="text" name="usernames " id="bianhao2" placeholder="B相 " class="w25" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" />/<input type="text" name="usernames " id="bianhao3" placeholder="C相 " class="w25" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" />

			</div>
			<div class="sp-group android">
				<label for=" ">今日数据：</label><input type="tel" name="usernames " id="bianhao1" placeholder="A相 " class="w25" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" />/<input type="tel" name="usernames " id="bianhao2" placeholder="B相 " class="w25" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" />/<input type="tel" name="usernames " id="bianhao3" placeholder="C相 " class="w25" onkeyup="value=value.replace(/[^\d{1,}\.-\d{1,}|\d{1,}]/g,'')" />

			</div>
			<div class="chart" id="lineChart1"></div>
			<div class="tishi"></div>
			<div class="sp-submit">
				<div class="sp-submit-quit1">
					取消
				</div>
				<div class="sp-submit-sure1">
					确定
				</div>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/jquery-3.1.1.js"></script>
		<script src="../../js/vue.js"></script>
		<script type="text/javascript" src="../../js/mkeyplus.base.xunjian.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
		<script type="text/javascript" src="./js/mui.previewimage.js"></script>
		<script type="text/javascript" src="./js/mui.zoom.js"></script>
		<script type="text/javascript" src="../../js/uuid.js"></script>
		<script type="text/javascript" src="./js/up.js"></script>
		<script type="text/javascript" src="./js/websql.js"></script>
		<script type="text/javascript" src="./js/echarts.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.previewImage();
			var userxjId = "";
			var sb_id = "";
			var rateid;
			var rate;
			var scancode;
			var smTime;
			var xsdwindid;
			var offlinetype = '';
			var from = '';
			var tjtype = '';
			var vm = new Vue({
				el: "#lineChart",
				data: {
					DATE: [],
					TITLE: {},
					NUMBER: []
				}
			});
			var vm1 = new Vue({
				el: "#lineChart1",
				data: {
					DATE: [],
					NUMBERA: [],
					NUMBERB: [],
					NUMBERC: []
				}
			});
			//			var userxjId=" ";
			//点击弹出输入框
			var _width = $('#topPopover').width();
			$("#lineChart").css('width', _width + 'px');
			$("#lineChart1").css('width', _width + 'px');
			$(".xj-content").on("tap", ".input", function() {

				var type = $(this).attr('data-type');
				var data_type = $(this).parents().parents().attr('data-type');
				var Text = $(this).parents().siblings('em').html();
				var value = $(this).val(); //填写值回显
				var data_id = $(this).parents().siblings('.mui-card-header').attr('data-id');
				console.log('Text='+Text);
				if(~Text.indexOf('温度')){
					$('.ifshowssd').css('display', 'block');
				}else{
					$('.ifshowssd').css('display', 'none');
				}
				$('#topPopover').attr('data-type', type);
				$('#topPopover').find('h4').html(Text);
				$('#topPopover').find('label').html(Text);
				$('#topPopover').find('input').val(value);
				mui('#topPopover').popover('show');
				mui.baseApp.httpRequst('/api/v2/sbxj/numberXjStatistics', {
						jcx_id: data_id,
						sb_id: sb_id,
						type: data_type
					},
					function(res) {
						console.log("数据列表" + JSON.stringify(res));
						var data = res.data;

						//						var sbInfo = data.sbInfo;
						if(res.status == 200) {
							localStorage.setItem('personal', JSON.stringify(data))
							vm.TITLE = data.jcxInfo.desc_name;
							console.log("数据列表标题" + JSON.stringify(vm.TITLE));
							convert(vm, data.xList);
							convert1(data.numberList);
							var myChart = echarts.init(document.getElementById('lineChart'));
							myChart.setOption(getoptions1());

							//								myChart1.setOption(getoptions1());
						} else if(res.status == 409) {
							mui.toast(data.message)
						}
					}
				);

			});
			$(".xj-content").on("tap", ".input_vol", function() {
				var type = $(this).attr('data-i');
				var data_type = "2";
				var Text = $(this).find('em').html();
				var value1 = $(this).find('input.input_v:eq(0)').val();
				var value2 = $(this).find('input.input_v:eq(1)').val();
				var value3 = $(this).find('input.input_v:eq(2)').val();
				console.log(value3);
				var data_id = $(this).parents().siblings('.mui-card-header').attr('data-id');
				$('#topPopover1').attr('data-type', type);
				$('#topPopover1').find('h4').html(Text);
				$('#topPopover1').find('label').html(Text);
				$('#topPopover1').find('input#bianhao1').val(value1);
				$('#topPopover1').find('input#bianhao2').val(value2);
				$('#topPopover1').find('input#bianhao3').val(value3);
				mui('#topPopover1').popover('show');
				mui.baseApp.httpRequst('/api/v2/sbxj/numberXjStatistics', {
						jcx_id: data_id,
						sb_id: sb_id,
						type: data_type
					},
					function(res) {
						console.log("数据列表" + JSON.stringify(res));
						var data = res.data;
						if(res.status == 200) {
							localStorage.setItem('personal', JSON.stringify(data))
							convert(vm1, data.xList);
							vm1.NUMBERA = data.aList;
							vm1.NUMBERB = data.bList;
							vm1.NUMBERC = data.cList;
							var myChart = echarts.init(document.getElementById('lineChart1'));
							myChart.setOption(getoptions2());

							//								myChart1.setOption(getoptions1());
						} else if(res.status == 409) {
							mui.toast(data.message)
						}
					}
				);

			});
			document.querySelector('.sp-submit-quit').addEventListener('tap', function() {
				mui('#topPopover').popover('hide');
			})
			$('.sp-submit').on('tap', '.sp-submit-sure', function() {
				mui('#topPopover').popover('hide');
				var Text = $(this).parents().find('input#bianhao').val();
				var type = $(this).parents().parents().attr('data-type');
				var inputList = $('.input');
				for(var i = 0; i <= inputList.length; i++) {
					if(type == $('.input').eq(i).attr('data-type')) {						
						$('.input').eq(i).val(Text);
					}
				}

			})
			$('.sp-submit').on('tap', '.sp-submit-sure1', function() {
				mui('#topPopover1').popover('hide');
				var Text1 = $(this).parents().find('input#bianhao1').val();
				var Text2 = $(this).parents().find('input#bianhao2').val();
				var Text3 = $(this).parents().find('input#bianhao3').val();
				var type = $(this).parents().parents().attr('data-type');
				var inputList = $('.input_vol');
				for(var i = 0; i <= inputList.length; i++) {
					if(type == $('.input_vol').eq(i).attr('data-i')) {
						$('.input_vol').eq(i).find('input').eq(0).val(Text1);
						$('.input_vol').eq(i).find('input').eq(1).val(Text2);
						$('.input_vol').eq(i).find('input').eq(2).val(Text3);
					}
				}

			})
			document.querySelector('.sp-submit-quit1').addEventListener('tap', function() {
				mui('#topPopover1').popover('hide');
			})
			mui.plusReady(function() {
				if(mui.os.ios){
					$('.android').remove();
				}else{
					$('.ios').remove();
				}
				var self = plus.webview.currentWebview();
				var opener = self.opener();
				from = self.from;
				tjtype = self.type;
				if(self.type && self.type == 'scan'){
					opener.close('none');
				}
				rate = self.index;
				scancode = self.scancode;
				smTime = self.smTime;
				xsdwindid = self.xsdwindid;
				offlinetype = self.offlinetype;
				console.log('scancode='+scancode);
				console.log('rate='+rate);
				console.log('xsdwindid='+xsdwindid);
				console.log('smTime='+smTime);
				console.log('from='+from);
				console.log('type='+self.type);
				console.log('offlinetype='+self.offlinetype);
				if (plus.networkinfo.getCurrentType()  ==  plus.networkinfo.CONNECTION_NONE)  {
					$('.chart').css('display', 'none');
					$('.tishi').text('啊哦，数据飞走了~~~');

					websqlOpenDB();               
					console.log("查找全部数据 ");                                         
					websqlGetAllData(jcxInfoTable);             
					websqlGetAData(sbInfoTable, scancode, parseInt(rate));

					tap();
				} else {
					var _interface = '';
					var data = {
						memberId: localStorage.getItem('userid'),
						scancode: scancode,
						rate: rate
					}
					if(from == 'shebei'){
						_interface =  '/api/v2/sbxj/getSbScanCode';
					}else{
						_interface =  '/api/v2/sbxj/createUserXj';
						data.xsdWindId = xsdwindid
					}
					mui.baseApp.httpRequst(_interface,  data, function(res) {
						console.log("巡检项 " + JSON.stringify(res));
						if(res.data == null){
							setTimeout(()=>{
								plus.webview.currentWebview().opener().close('none');
								plus.webview.currentWebview().close('none');
							},1500)
							mui.toast(res.message);
							return;
						}
						if(res.status == 200) {
							var data = res.data;
							var jcxList = data.jcxList;
							userxjId = data.userxjId;
							name = data.sbInfo.name;
							sb_id = data.sbInfo.id
							console.log(JSON.stringify(jcxList));
							data_sucess(jcxList);

						} else if(res.data == 400) {
							mui.toast('密码不正确!');
						} else if(res.data == 409) {
							mui.toast('用户不存在!');
						}

					}, function() {
						plus.nativeUI.closeWaiting();
						console.log("获取列表项失败 ");
					});

				};
				//				打开设备信息页面
				document.querySelector('#shebei').addEventListener('tap', function() {
					mui.openWindow({
						id: "shebeixinxi.html",
						url: "shebeixinxi.html",
						waiting: {
							autoShow: false, //自动显示等待框，默认为true
						},
						extras: {
							scancode: scancode,
							index: rate,
							xsdwindid:xsdwindid
						}
					});
				});

			});

			//			成功调取数据后获取
			function data_sucess(jcxList) {
				var table = document.body.querySelector('.xj-content');
				$('#shebeimc span').text(name);
				table.id = userxjId;
				for(var i = 0; i < jcxList.length; i++) {
					if(jcxList[i].type == 0) {
						var div = document.createElement('div');
						div.className = 'mui-card';

						var str = '<div class="mui-card-header"data-id="' + jcxList[i].mbmx_id + '"><div class="mui-left fs15 Title mui-col-sm-10 mui-col-xs-10">' + jcxList[i].name + '</div></div>' + '<div class="mui-card-content"><div class="mui-row form-row fs15 pd5">检查标准：' + jcxList[i].standard + '</div><div class="mui-row"><div class="form-row mui-pull-left"><em class="mui-pull-left desc_name">' + jcxList[i].desc_name + ':</em>	<div class="radio mui-pull-left"data-type="0"><form action=""><div class="mui-radio mui-pull-left">	<label>正常</label><input name="radio1" type="radio" value="正常" checked></div><div class="mui-radio mui-pull-left"><label>异常</label><input name="radio1" type="radio" value="异常"></div></form></div></div>	<div class="mui-pull-right yichang hide"><button type="button" class="mui-btn mui-btn-primary">异常填写</button>	</div>	</div><p class="beizhu"></p><div class="img-up">	<div class="photo"id="">	<img src="" alt="" class="headimg" data-preview-src=""data-preview-group="' + (i + 1) + '"/><span class="mui-icon mui-icon-closeempty delete"></span></div><div class="img" id="userImg"><span class="mui-icon mui-icon-image"></span><p>拍照上传</p></div></div></div>';
						div.innerHTML = str;
						table.appendChild(div);
					} else if(jcxList[i].type == 1) {
						if(jcxList[i].name == '温度'){
							var div = document.createElement('div');
							div.className = 'mui-card';
							var str = '<div class="mui-card-header "data-id="' + jcxList[i].mbmx_id + '"><div class="mui-left fs15 Title mui-col-sm-10 mui-col-xs-10 ">' + jcxList[i].name + '</div></div>' + '<div class="mui-card-content"><div class="mui-row form-row fs15 pd5">检查标准：' + jcxList[i].standard + '</div><div class="mui-row "><div class="form-row mui-pull-left "><em class="mui-pull-left desc_name">' + jcxList[i].desc_name + ':</em>	<div class="radio mui-pull-left "data-type="1"><form action=" "><input type="text " class="input" data-type="' + i + '"readonly/><font class="fs15">℃</font></form></div></div><div class="mui-pull-right yichang"><button type="button " class="mui-btn mui-btn-primary">异常填写</button></div></div><p class="beizhu"></p><div class="img-up "><div class="photo"id=""><img src="" alt="" class="headimg" data-preview-src="" data-preview-group="' + (i + 1) + '"/><span class="mui-icon mui-icon-closeempty delete"></span></div><div class="img" id="userImg"><span class="mui-icon mui-icon-image"></span><p>拍照上传</p></div></div></div>';
							div.innerHTML = str;
							table.appendChild(div);
						}else{
							var div = document.createElement('div');
							div.className = 'mui-card';
							var str = '<div class="mui-card-header "data-id="' + jcxList[i].mbmx_id + '"><div class="mui-left fs15 Title mui-col-sm-10 mui-col-xs-10 ">' + jcxList[i].name + '</div></div>' + '<div class="mui-card-content"><div class="mui-row form-row fs15 pd5">检查标准：' + jcxList[i].standard + '</div><div class="mui-row "><div class="form-row mui-pull-left "><em class="mui-pull-left desc_name">' + jcxList[i].desc_name + ':</em>	<div class="radio mui-pull-left "data-type="1"><form action=" "><input type="text " class="input" data-type="' + i + '"readonly/><font class="fs15"></font></form></div></div><div class="mui-pull-right yichang"><button type="button " class="mui-btn mui-btn-primary">异常填写</button></div></div><p class="beizhu"></p><div class="img-up "><div class="photo"id=""><img src="" alt="" class="headimg" data-preview-src="" data-preview-group="' + (i + 1) + '"/><span class="mui-icon mui-icon-closeempty delete"></span></div><div class="img" id="userImg"><span class="mui-icon mui-icon-image"></span><p>拍照上传</p></div></div></div>';
							div.innerHTML = str;
							table.appendChild(div);
						}
					} else if(jcxList[i].type == 2) {
						var div = document.createElement('div');
						div.className = 'mui-card';

						var str = '<div class="mui-card-header "data-id="' + jcxList[i].mbmx_id + '"><div class="mui-left fs15 Title mui-col-sm-10 mui-col-xs-10">' + jcxList[i].name + '</div></div>' + '<div class="mui-card-content"><div class="mui-row form-row fs15 pd5">检查标准：' + jcxList[i].standard + '</div><div class="mui-row"><div class="form-row mui-pull-left "><div class="radio mui-pull-left input_vol"data-type="2"data-i="' + i + '"><em class="desc_name">' + jcxList[i].desc_name + ':</em><form action="" class="voltage"><label for="">A:</label><input type="text" class="input_v" readonly="readonly" /><label for="">B:</label><input type="text" class="input_v" readonly="readonly" /><label for="">C:</label><input type="text" class="input_v" readonly="readonly"/></form></div></div><div class="mui-pull-right yichang "><button type="button" class="mui-btn mui-btn-primary">异常填写</button></div></div><p class="beizhu"></p><div class="img-up"><div class="photo"id=""><img src="" alt="" class="headimg" data-preview-src="" data-preview-group="' + (i + 1) + ' "/><span class="mui-icon mui-icon-closeempty delete"></span></div><div class="img" id="userImg"><span class="mui-icon mui-icon-image"></span><p>拍照上传</p></div></div></div>';
						div.innerHTML = str;
						table.appendChild(div);
					}
				}

				tap();
			}

			function tap() {
				$('.mui-card-content .yichang').on('tap', function() {
					var $_title = $(this).parents().siblings().children('.Title').text();
					var $_Ltitle = $(this).parents().siblings().children('.mui-right-title').text();
					var data_id = $(this).parents().siblings('.mui-card-header').attr('data-id');
					var Text = $(this).parents().children('.beizhu').text();
					//					alert(Text);
					//					alert(Text);
					var imgSrc = $(this).parents().children('.img-up').find('img').attr('src');
					var attach = $(this).parents().children('.img-up').find('.photo').attr('id');
					console.log(data_id);
					mui.openWindow({
						id: "tianxie.html",
						url: "tianxie.html",
						//						show: {
						//							aniShow: 'pop-in'
						//						},
						waiting: {
							autoShow: false, //自动显示等待框，默认为true
						},
						extras: {
							title: $_title,
							Ltitle: $_Ltitle,
							data_id: data_id,
							Text: Text,
							imgSrc: imgSrc,
							attach: attach
						}
					});
				})
				$(".mui-card").on("tap", ".mui-right-title", function() {
					var Text = $(this).children('span').text()
					mui.alert(Text, '巡检标准', function() {});
				})
				$(".mui-card").on("tap", ".Title", function() {
					var Text = $(this).text()
					mui.alert(Text, '巡检项名称', function() {});
				})
				//					选择异常按钮
				$(".radio input:radio").on("click", function() {
					var num = $(this).val();
					console.log(num);
					if(num == '异常') {
						$(this).parents().siblings('.yichang').show()
						$(this).parentsUntil('.mui-card').find('.delete').hide()
					} else {
						$(this).parents().siblings('.yichang').hide();
//						alert($(this).parentsUntil('.mui-card').find(".beizhu").text());
						$(this).parentsUntil('.mui-card').find(".beizhu").text('');
						$(this).parentsUntil('.mui-card').find('.delete').show()
//						alert($(this).parentsUntil('.mui-card').find(".beizhu").text());
						
					}

				});
				//	异常填写传值
				window.addEventListener("Change", function(e) {
					
					var list = $('.mui-card');
					for(var i = 0; i < list.length; i++) {
						var data_id = $(list[i]).children('.mui-card-header').attr('data-id');
						var dataId = e.detail.dataId || "";
						if(data_id == dataId) {
							$(list[i]).find('.img').hide();
							$(list[i]).find('.photo').show();
							var img = e.detail.img;
							var attach = e.detail.attach;
							$(list[i]).find('.headimg').attr('src', img);
							$(list[i]).find('.photo').attr('id', attach);

							var Text = e.detail.Text;
							$(list[i]).find('.beizhu').text(Text);
							//								var Text=e.detail.Text;
						}
					}

				});
				//	拍照上传
				$(".mui-card .img-up").on("tap", ".img", function() {
					var $img = $(this).parents().parents().parents('div');
					$img.addClass("selectLi");
					$img.siblings().removeClass("selectLi");
					page.imgUp();
				})
				//删除图片
				$(".mui-card").on("tap", ".delete", function() {
					//					alert('222');
					var H1 = $(this).parent();
					var img_btn = $(this).parents().children('.img');
					var img_s = $(this).siblings('img');
					//					alert(img_s);
					var img_id = $(this).parents('.photo');
					var btnArray = ['否', '是'];
					mui.confirm('确定删除吗', '提示', btnArray, function(e) {
						if(e.index == 1) {
							H1.hide();
							img_btn.show();
							img_s.attr('src', "");
							img_id.attr('id', "");
						} else {}
					})
				})

				//确定到提交页面
				$('#sure').on('tap', function() {
					var list = $('.mui-card');
					/*var userxjId = $('.xj-content').attr('id');
					var name=$('#shebeimc span').text();*/
					//						alert(name);
					var arr = [];
					for(var i = 0; i < list.length; i++) {
						var obj = {};
						obj.Title = $(list[i]).find('.Title').text(); //巡检项目名称
						obj.desc = $(list[i]).find('.beizhu').text(); //备注
						obj.desc_name = $(list[i]).find('.desc_name').text(); //状态名称
						obj.id = $(list[i]).find('.mui-card-header').attr('data-id'); //巡检项id
						var data_type = $(list[i]).find(".radio ").attr('data-type'); //巡检项类型
						if(data_type == 0) {
							obj.staus = $(list[i]).find('input[type=radio]:checked').val(); //状态值
						} else if(data_type == 1) {
							obj.staus = $(list[i]).find('input').val();
						} else if(data_type == 2) {
							var stauslist = [];
							for(var j = 0; j < $(list[i]).find('input').length; j++) {
								var input_l = {};
								var Value = $(list[i]).find('input').eq(j).val()
								input_l.value = Value;
								stauslist.push(input_l);
								obj.staus = stauslist
							}
						}
						obj.data_type = data_type;
						obj.img_src = $(list[i]).find('img').attr('src');
						var attach = $(list[i]).find('.photo').attr('id');
						if(attach == undefined) {
							obj.attach = " ";
						} else {
							obj.attach = attach;
						}

						//							alert(obj.attach);
						arr.push(obj);
					}
					console.log(JSON.stringify(arr));
					var staus = [];
					var img_src = [];
					var desc = [];
					for(var i = 0; i < arr.length; i++) {
						staus[i] = arr[i].staus;
						img_src[i] = arr[i].img_src;
						desc[i] = arr[i].desc;
					}
					var index = $.inArray(" ", staus);
					var index1 = $.inArray(" ", img_src);
					var index2 = $.inArray(" ", desc);
					console.log(JSON.stringify(staus));
					console.log("++++++++" + JSON.stringify(arr));
					for(var i = 0; i < staus.length; i++) {
						//						isArray(o)
						console.log(staus.length);
						console.log(isArray(staus[i]));
						if(isArray(staus[i]) == true) {
							if(staus[i][0].value== ""||staus[i][1].value== ""||staus[i][2].value== "") {
								mui.toast("请填写状态值");
								return;
							}

						} else {
							if(staus[i] == "") {
								mui.toast("请填写状态值");
								return;
							} else if(staus[i] == "异常") {
								if(arr[i].desc == "") {
									mui.toast("请填写异常备注");
									return;
								}
							}
						}

					}

					if(index == -1) {
						mui.openWindow({
							id: "tijiao.html",
							url: "tijiao.html",
							waiting: {
								autoShow: false, //自动显示等待框，默认为true
							},
							extras: {
								list: arr,
								userxjId: userxjId,
								xsdwindid:xsdwindid,//新增 巡视点ID
								name: name,
								smTime: smTime,
								scancode: scancode,
								index: rate,
								from:from,
								type:tjtype,
								offlinetype:offlinetype
							}
						});
					} else {
						mui.toast('请填写完成状态值！');
					}

				})

			}
			//判断是否为数组
			function isArray(o) {
				return Object.prototype.toString.call(o) == '[object Array]';

			}

			function success(sbInfo_) {
				var sbInfo_list = sbInfo_.List;
				console.log('sbInfo_list' + JSON.stringify(sbInfo_list));
				name = sbInfo_list.name;
				rateid = sbInfo_list.rateid;
				websqlGetAData_(jcxInfoTable, rateid);
			}

			function success_(jcxInfo) {
				var jcxInfo_list = jcxInfo.List;
				console.log('jcxInfo_list==========='+JSON.stringify(jcxInfo_list));
				data_sucess(jcxInfo_list);
			}

			function convert(name, items) {
				name.DATE = [];
				items.forEach(function(item) {
					name.DATE.push(item.submit_time);
				});
			}

			function convert1(items) {
				vm.NUMBER = [];
				items.forEach(function(item) {
					vm.NUMBER.push(item.status);
				});
				console.log(JSON.stringify(vm.NUMBER));
			}
			// 基于准备好的dom，初始化echarts实例

			var getoptions1 = function() {

				var options = {
					title: {
						text: '',
						subtext: '' //纯属虚构
					},
					tooltip: {
						trigger: 'axis',
						axisPointer: {
							type: 'none',
							axis: 'y'
						},
						formatter: function(params) {
							return vm.TITLE + '：' + params[0].data;
						}
					},
					legend: {
						data: []
					},
					toolbox: {},
					grid: {
						left: '3%',
						bottom: '10%',
						top: "6%",
						containLabel: true
					},
					xAxis: {
						type: 'category',
						data: vm.DATE,
						axisLabel: {
							interval: 0, //横轴信息全部显示
							rotate: -30, //-30度角倾斜显示
						}
					},
					yAxis: {
						type: 'value',
						axisLabel: {
							formatter: '{value}'
						}
					},
					series: [{
						name: vm.TITLE,
						type: 'line',
						data: vm.NUMBER,
						symbolSize: 10,
						markPoint: {
							data: []
						},
						markLine: {
							data: [{
								type: 'average',
								name: '平均值'
							}]
						},
						itemStyle: {
							normal: {
								color: '#2e73f6'
							}
						}
					}]
				};
				return options;
			}
			var getoptions2 = function() {

				var options1 = {
					title: {
						text: '',
						subtext: '' //纯属虚构
					},
					grid: {
						left: '3%',
						bottom: '10%',
						top: "12%",
						containLabel: true
					},
					tooltip: {
						trigger: 'axis',
						axisPointer: {
							type: 'none',
							axis: 'y'
						},

						formatter: function(params) {
							for(var i = 0; i < options1.series.length; i++) {
								return params[i].seriesName + '：' + params[i].data;
							}

							//							return vm.TITLE + '：' + params[0].data;
						}
					},
					legend: {
						data: ['A', 'B', 'C']
					},
					toolbox: {},
					xAxis: {
						type: 'category',
						data: vm1.DATE,
						axisLabel: {
							interval: 0, //横轴信息全部显示
							rotate: -30, //-30度角倾斜显示
						}
					},
					yAxis: {
						type: 'value',
						axisLabel: {
							formatter: '{value}'
						}
					},
					series: [{
						name: 'A',
						type: 'line',
						data: vm1.NUMBERA,
						symbolSize: 10,
						markPoint: {
							data: []
						},
						markLine: {
							data: [{
								type: 'average',
								name: '平均值'
							}]
						},
						itemStyle: {
							normal: {
								color: '#FFC125'
							}
						}
					}, {
						name: 'B',
						type: 'line',
						data: vm1.NUMBERB,
						symbolSize: 10,
						markPoint: {
							data: []
						},
						markLine: {
							data: [{
								type: 'average',
								name: '平均值'
							}]
						},
						itemStyle: {
							normal: {
								color: '#4a7f39'
							}
						}
					}, {
						name: 'C',
						type: 'line',
						data: vm1.NUMBERC,
						symbolSize: 10,
						markPoint: {
							data: []
						},
						markLine: {
							data: [{
								type: 'average',
								name: '平均值'
							}]
						},
						itemStyle: {
							normal: {
								color: '#ff0000'
							}
						}
					}]
				};
				return options1;
			}
		</script>
	</body>

</html>